varying vec3 varyingNormal;
varying vec3 varyingNormal1;
varying vec3 varyingViewDir;
varying vec3 varyingDiffColor;
varying vec3 positions;
float alpha = 6.0;
float lightIntensity = 1.0;
float ks = 0.5;
vec3 lightPos = vec3(10.0, 10.0, 10.0); //direction in camera coordinate
vec3 kd = vec3(0.3, 0.3, 0.3);
vec3 ambient = vec3(0.2, 0.2, 0.2);
void main(void)
{
                vec3 l = normalize(-varyingViewDir+lightPos);
        vec3 v = normalize(-varyingViewDir);
        vec3 n = normalize(varyingNormal);
        vec3 r = normalize(-reflect(l,n));
        //diffuse
        vec3 Idiff = kd*max(dot(n,l),0.0)*lightIntensity;
        Idiff = clamp(Idiff, 0.0, 1.0);

        //specular
        vec3 Ispec = ks*pow(max(dot(r,v),0.0), alpha) * lightIntensity;
        Ispec = clamp(Ispec, 0.0, 1.0);

        gl_FragColor.rgb = ambient + Idiff + Ispec;

//  gl_FragColor.r = 2.3;
//  gl_FragColor.g = 4.4;
//  gl_FragColor.b = 5.5;
}
